package org.example.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.example.bean.Orderdetail;
import org.example.service.OrderdetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/orderdetail")
@Tag(name = "订单详情管理",description = "实现对订单详情的增删改查工作")
public class OrderdetailController {
    @Autowired
    private OrderdetailService orderService;
    @PostMapping("/add/{order_id}/details")
    public ResponseEntity<ResponseResult> addDetails(
            @PathVariable("order_id") Integer order_id,
            @RequestBody List<Orderdetail> detailList) {
        boolean success = orderService.addOrderDetail(order_id, detailList);
        return ResponseEntity.ok(ResponseResult.builder().code(1).msg("添加成功").data(success).build());
    }

}
